import { order } from "@/api/index.js";
import { mapState } from "vuex";
import { regExpConfig } from "@/libs/regular.js";
export default {
  data () {
    return {
      isFeeble: false,
      isMiddle: false,
      isStrong: false,
      isNewFeeble: false,
      isNewMiddle: false,
      isNewStrong: false,
      passwordTips: '',
      affirmPasswordTips: ''
    };
  },

  methods: {
    // 输入新密码input的事件
    onInput (value) {
      if (!value) {
        this.isMiddle = false;
        this.isFeeble = false;
        this.isStrong = false;
        return;
      }
      if (regExpConfig.strongContent.test(value)) {
        this.isMiddle = false;
        this.isFeeble = false;
        this.isStrong = true;
      } else if (regExpConfig.middleSpecial.test(value)) {
        this.isFeeble = false;
        this.isStrong = false;
        this.isMiddle = true;
      } else {
        this.isStrong = false;
        this.isMiddle = false;
        this.isFeeble = true;
      }
    },
    // 确认新密码input的事件
    newOnInput (value) {
      if (!value) {
        this.isNewMiddle = false;
        this.isNewFeeble = false;
        this.isNewStrong = false;
        return;
      }
      if (regExpConfig.strongContent.test(value)) {
        this.isNewMiddle = false;
        this.isNewFeeble = false;
        this.isNewStrong = true;
      } else if (regExpConfig.middleSpecial.test(value)) {
        this.isNewFeeble = false;
        this.isNewStrong = false;
        this.isNewMiddle = true;
      } else {
        this.isNewStrong = false;
        this.isNewMiddle = false;
        this.isNewFeeble = true;
      }
    },
    // 确认新密码失去焦点时
    newLoseBlur () {
      if (this.isNewFeeble) {
        this.affirmPasswordTips = `密码强度不够，至少要包含数字，字母，特殊字符三项中两项！`
        return
      } else {
        this.affirmPasswordTips = ''
      }
    },
    // 输入新密码失去焦点时
    loseBlur () {
      if (this.isFeeble) {
        this.passwordTips = `密码强度不够，至少要包含数字，字母，特殊字符三项中两项！`
        return
      } else {
        this.passwordTips = ''
      }
    }
  }
};
